package com.welike.shibo.eneity;

import com.welike.shibo.enums.ResultEnum;
import com.welike.shibo.utils.Tools;
import lombok.Data;

import java.util.Map;

/**
 * 请求结果
 * @author fangyu
 * @version v1.0.0
 * @since 2019-08-19 00:21
 */
@Data
public class JsonResult {
    /**
     * code 返回码
     * message 返回消息
     * data 数据源
     * time 请求时间
     */
    private Integer code;
    private String message;
    private Map<String, Object> data;
    private String time = Tools.newDate();

    public JsonResult() {
    }

    public JsonResult(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public JsonResult(Integer code, String message, Map<String, Object> data) {
        super();
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public JsonResult(ResultEnum resultEnum, Map<String, Object> data) {
        super();
        this.code = resultEnum.getCode();
        this.message = resultEnum.getMsg();
        this.data = data;
    }
}
